#include "app_buffer.h"
#include "log/log.h"

int main(int argc, char const *argv[])
{
    //初始化缓冲区
    Buffer *buffer = app_buffer_init(15);

    //写入数据1
    app_buffer_write(buffer, "abcde", 5);

    //写入数据2
    app_buffer_write(buffer, "fghijk", 6);

    //读取数据1
    char data_buf[10];
    int len = app_buffer_read(buffer, data_buf, 10);
    log_debug("read data 1: %.*s, len: %d",len , data_buf, len);

    //读取数据2
    char data_buf2[10];
    int len2 = app_buffer_read(buffer, data_buf2, 10);
    log_debug("read data 2: %.*s, len: %d",len2 , data_buf2, len2);

    //没有数据
    char data_buf3[10];
    int len3 = app_buffer_read(buffer, data_buf3, 10);
    log_debug("read data 3: %.*s, len: %d",len3 , data_buf3, len3);

    //写入的数据过多
    app_buffer_write(buffer, "111111111111111", 15);


    return 0;
}